/ Assembly List / LJCNetCommon / NetCommon / XmlSerializeToString

Namespace - LJCNetCommon


Parameters
type - The object type.
data - The object reference.
namespaces - The XML namespaces.

Returns

The XML message string.

Syntax

C#
public static String XmlSerializeToString(Type type, Object data, XmlSerializerNamespaces namespaces)

Serialize an object to an XML message string. (E)

Example

C#
using LJCNetCommon;
        
public class Person
{
  public long Id { get; set; }
  public string Name { get; set; }
  public bool PrincipleFlag { get; set; }
}

// Serialize an object to an XML message string.
private static void XmlSerializeToString()
{
  // Serialize an object to an XML message string.
  var person = new Person()
  {
    Id = 2,
    Name = "Text",
    PrincipleFlag = true
  };
  string message = NetCommon.XmlSerializeToString(person.GetType(), person, null);

  // Check the object.
  Person newPerson;
  newPerson = NetCommon.XmlDeserializeMessage(typeof(Person), message) as Person;
}

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.